﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using HZ.Supervise.Model;
using System.Text;
using System.Web.UI.DataVisualization.Charting;
using System.Data;
using HZ.Supervise.Model.Enum;

namespace HZ.Supervise.Web.Secondphase.Comparison
{
    public partial class ComparisonByArea : BasePage
    {
        DataTable dt = new DataTable();
        string[] aid;
        string timefrom;
        string timeto;
        string aids;

        protected void Page_Load(object sender, EventArgs e)
        {
            timefrom = Request["timefrom"].Trim();
            timeto = Request["timeto"].Trim();
            aid = Request["Aid"].Split(',');
            aids = Request["Aid"];
            if (!IsPostBack)
            {
                dataBind();

                BindChart();
            }
        }
        /// <summary>
        /// 数据绑定
        /// </summary>
        public void dataBind()
        {

            HZ.Supervise.IBLL.IExecuteContext ie = HZ.Supervise.BLLFactory.ExecuteContext();

            string where1 = "";

            string where2 = "";

            foreach (string item in aid)//add by 曹鹏 2011年5月5日9:04:40 区分用户选中的是市，还是县区，然后做不同的查询（因为市的数据是它下面所有县区数据的和，故此分开查询）
            {

                if (!string.IsNullOrEmpty(item))
                {

                    if (item.Substring(4, 2).Equals("00"))
                    {

                        where1 = where1 + (" AreaId  like '" + item.Substring(0, 4) + "%' or ");//如果选中市

                    }
                    else
                    {

                        where2 = where2 + ("AreaId = '" + item + " ' or ");//如果选中县区

                    }
                }

            }

            System.Data.DataTable dt1 = null;

            System.Data.DataTable dt2 = null;

            if (!string.IsNullOrEmpty(where1))
            {

                where1 = " and (" + where1 + " 1=2)";//由于字符串末尾有“or”，所以加上“1=2”，意在去掉“or”

                if (string.IsNullOrEmpty(timeto) || string.IsNullOrEmpty(timefrom)) { }
                else
                {

                    where1 += " and (" + this.timeto + ">=DayTime and DayTime>=" + this.timefrom + ")";
                }
                dt1 = ie.ExecuteAreaIDByCity(where1);//取出市的数据
            }

            if (!string.IsNullOrEmpty(where2))
            {

                where2 = "and (" + where2 + " 1=2)";

                if (string.IsNullOrEmpty(timefrom) || string.IsNullOrEmpty(timeto)) { }
                else
                {
                    where2 += " and (" + this.timeto + ">=DayTime and DayTime>=" + this.timefrom + ")";
                }
                dt2 = ie.ExecuteAreaIDOfCountry(where2);//取出县区的数据

            }

            if (dt1 == null)
            {
                dt = dt2.Copy();
                HZ.Supervise.Web.Function.ChangeRate(dt2, "DistributeRate", "addDistributeRate");
                HZ.Supervise.Web.Function.AddColumn(dt2, "WareHouseRate", "SortSource");

                gvwAreaComparison.DataSource = dt2;
            }

            else if (dt2 == null)
            {
                dt = dt1.Copy();
                HZ.Supervise.Web.Function.ChangeRate(dt1, "DistributeRate", "addDistributeRate");
                HZ.Supervise.Web.Function.AddColumn(dt1, "WareHouseRate", "SortSource");

                gvwAreaComparison.DataSource = dt1;

            }

            else
            {

                foreach (DataRow item in dt1.Rows)
                {

                    dt2.Rows.Add(item["AreaName"], item["AreaId"], item["SortSource"], item["PurchaseAmountTotal"], item["DistributeAmountTotal"], item["WarehouseAmountTotal"], item["DistributeRate"], item["WareHouseRate"]);

                }

                dt = dt2.Copy();

                HZ.Supervise.Web.Function.ChangeRate(dt2, "DistributeRate", "addDistributeRate");

                HZ.Supervise.Web.Function.AddColumn(dt2, "WareHouseRate", "SortSource");

                dt2.DefaultView.Sort = "areaname,SortSource asc";//两个datatable合并之后，需要重新排序以便合并单元格

                gvwAreaComparison.DataSource = dt2;

            }

            gvwAreaComparison.DataBind();

            HZ.Supervise.Web.Function.Combine(gvwAreaComparison);//单元格合并
        }

        public string getSortSource(object SortSource)
        {
            return HZ.Supervise.Web.Function.FormatDrugSourceByName(SortSource.ToString()).Trim();
        }
        /// <summary>
        /// 曹鹏
        /// 2011年4月27日10:21:30
        /// 行绑定事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvwProcureCatalog_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {

                e.Row.Cells[2].Text = HZ.Supervise.Web.Function.GetCityNameByCountryName(e.Row.Cells[2].Text);

            }
        }
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {

        }

        protected void btnExcel_Click(object sender, EventArgs e)
        {

            HZ.Supervise.IBLL.IExecuteContext ie = HZ.Supervise.BLLFactory.ExecuteContext();

            string where1 = "";

            string where2 = "";

            foreach (string item in aid)//add by 曹鹏 2011年5月5日9:04:40 区分用户选中的是市，还是县区，然后做不同的查询（因为市的数据是它下面所有县区数据的和，故此分开查询）
            {

                if (!string.IsNullOrEmpty(item))
                {

                    if (item.Substring(4, 2).Equals("00"))
                    {

                        where1 = where1 + (" AreaId  like '" + item.Substring(0, 4) + "%' or ");//如果选中市

                    }
                    else
                    {

                        where2 = where2 + ("AreaId = '" + item + " ' or ");//如果选中县区

                    }
                }

            }

            System.Data.DataTable dt1 = null;
            System.Data.DataTable dt2 = null;
            if (!string.IsNullOrEmpty(where1))
            {

                where1 = " and (" + where1 + " 1=2)";//由于字符串末尾有“or”，所以加上“1=2”，意在去掉“or”
                if (string.IsNullOrEmpty(timefrom) || string.IsNullOrEmpty(timeto)) { }
                else
                {
                    where1 += " and (" + this.timeto + ">=DayTime and DayTime>=" + this.timefrom + ")";
                }
                dt1 = ie.ExecuteAreaIDByCity(where1);//取出市的数据
            }

            if (!string.IsNullOrEmpty(where2))
            {

                where2 = "and (" + where2 + " 1=2)";
                if (string.IsNullOrEmpty(timeto) || string.IsNullOrEmpty(timefrom)) { }
                else
                {
                    where2 += " and (" + this.timeto + ">=DayTime and DayTime>=" + this.timefrom + ")";
                }
                dt2 = ie.ExecuteAreaIDOfCountry(where2);//取出县区的数据

            }

            if (dt1 == null)
            {
                dt = dt2.Copy();

                HZ.Supervise.Web.Function.ChangeRate(dt2, "DistributeRate", "addDistributeRate");

                HZ.Supervise.Web.Function.AddColumn(dt2, "WareHouseRate", "SortSource");

                HZ.Excel.ExcelHelper.ExportDataForWeb(dt2, this.gvwAreaComparison);
            }

            else if (dt2 == null)
            {
                dt = dt1.Copy();

                HZ.Supervise.Web.Function.ChangeRate(dt1, "DistributeRate", "addDistributeRate");

                HZ.Supervise.Web.Function.AddColumn(dt1, "WareHouseRate", "SortSource");

                HZ.Excel.ExcelHelper.ExportDataForWeb(dt1, this.gvwAreaComparison);

            }

            else
            {

                foreach (DataRow item in dt1.Rows)
                {

                    dt2.Rows.Add(item["AreaName"], item["AreaId"], item["SortSource"], item["PurchaseAmountTotal"], item["DistributeAmountTotal"], item["WarehouseAmountTotal"], item["DistributeRate"], item["WareHouseRate"]);

                }

                dt = dt2.Copy();

                HZ.Supervise.Web.Function.ChangeRate(dt2, "DistributeRate", "addDistributeRate");

                HZ.Supervise.Web.Function.AddColumn(dt2, "WareHouseRate", "SortSource");

                DataView dv = dt2.DefaultView;

                dv.Sort = "areaname,SortSource asc";

                dt2 = dv.ToTable();

                HZ.Excel.ExcelHelper.ExportDataForWeb(dt2, this.gvwAreaComparison);

            }

        }

        #region 图表绑定 董辉 修改 2011-4-9 14:29

        /// <summary>
        /// 绑定金额与数量的图表数据
        /// 董辉
        /// 2011-4-9 14:20
        /// </summary>
        private void BindChart()
        {
            #region 变量

            //用于排序后的新的数据集合
            DataTable NewDatatable = new DataTable();

            //基本药物目录循环因子
            int BaseI = 0;

            //补充目录循环因子
            int ComplementI = 0;

            //2010基本药物循环因子
            int Base_2010I = 0;

            //2010限价品种循环因子
            int PriceFixing_2010I = 0;

            //2010补充药品循环因子
            int Complementarity_2010I = 0;

            //医院名称
            string AreaName = string.Empty;

            #endregion

            #region 将datatable按医院名称进行排序

            //声明dataview对象，并把dt传给dataview
            DataView dv = dt.DefaultView;

            //指定dataview按中文进行排序
            dv.Table.Locale = new System.Globalization.CultureInfo("zh-CN");

            //排序条件为医院
            dv.Sort = " AreaName desc ";

            //排序后的集合传给新的datatable
            NewDatatable = dv.ToTable();

            #endregion

            #region 构造序列集

            #region 采购金额序列集


            /***********************************************************************************************/

            //第一批基本药物采购金额序列
            Series BasicCatalog_2010_Money = new Series("日常采购");

            //设置图表类型为柱状图
            BasicCatalog_2010_Money.ChartType = SeriesChartType.Column;
            BasicCatalog_2010_Money.MarkerStyle = MarkerStyle.Diamond;
            // BasicCatalog_2010_Money.Color = Color.DarkGray;

            //设置图表边宽
            BasicCatalog_2010_Money.BorderWidth = 1;

            //设置图表偏移量
            BasicCatalog_2010_Money.ShadowOffset = 1;

            //画图类型
            //BasicCatalog_2010_Money["DrawingStyle"] = "Cylinder";

            /***********************************************************************************************/

            //2010限价品种采购金额序列
            Series PriceFixing_2010_Money = new Series("临时采购");

            //设置图表类型为柱状图
            PriceFixing_2010_Money.ChartType = SeriesChartType.Column;
            PriceFixing_2010_Money.MarkerStyle = MarkerStyle.Diamond;
            //PriceFixing_2010_Money.Color = Color.Blue;

            //设置图表边宽
            PriceFixing_2010_Money.BorderWidth = 1;

            //设置图表偏移量
            PriceFixing_2010_Money.ShadowOffset = 1;

            //画图类型
            //  PriceFixing_2010_Money["DrawingStyle"] = "Cylinder";

            /***********************************************************************************************/

            //2010补充药品采购金额序列
            Series ComplementarityCatalog_2010_Money = new Series("应急采购");

            //设置图表类型为柱状图
            ComplementarityCatalog_2010_Money.ChartType = SeriesChartType.Column;

            //ComplementarityCatalog_2010_Money.Color = Color.Red;
            ComplementarityCatalog_2010_Money.MarkerStyle = MarkerStyle.Diamond;
            //设置图表边宽
            ComplementarityCatalog_2010_Money.BorderWidth = 1;

            //设置图表偏移量
            ComplementarityCatalog_2010_Money.ShadowOffset = 1;

            //画图类型
            // ComplementarityCatalog_2010_Money["DrawingStyle"] = "Cylinder";



            BasicCatalog_2010_Money.Label = "#VAL{F}";
            BasicCatalog_2010_Money.Color = Color.FromArgb(74, 172, 197);

            PriceFixing_2010_Money.Label = "#VAL{F}";
            PriceFixing_2010_Money.Color = Color.FromArgb(129, 101, 162);
            ComplementarityCatalog_2010_Money.Label = "#VAL{F}";
            ComplementarityCatalog_2010_Money.Color = Color.FromArgb(192, 80, 78);


            #endregion

            /***********************************************************************************************/


            //2010基本药物配送率序列
            Series BasicCatalog_2010_PSRate = new Series("日常采购");

            //设置图表类型为柱状图
            BasicCatalog_2010_PSRate.ChartType = SeriesChartType.Column;

            BasicCatalog_2010_PSRate.Color = Color.DarkGray;

            //设置图表边宽
            BasicCatalog_2010_PSRate.BorderWidth = 1;

            //设置图表偏移量
            BasicCatalog_2010_PSRate.ShadowOffset = 1;

            BasicCatalog_2010_PSRate.IsValueShownAsLabel = true;

            BasicCatalog_2010_PSRate.Label = "#VAL{F}";

            BasicCatalog_2010_PSRate.Color = Color.FromArgb(74, 172, 197);

            /***********************************************************************************************/

            //2010限价品种配送率序列
            Series PriceFixing_2010_PSRate = new Series("临时采购");

            //设置图表类型为柱状图
            PriceFixing_2010_PSRate.ChartType = SeriesChartType.Column;

            //设置图表边宽
            PriceFixing_2010_PSRate.BorderWidth = 1;

            //设置图表偏移量
            PriceFixing_2010_PSRate.ShadowOffset = 1;

            PriceFixing_2010_PSRate.IsValueShownAsLabel = true;

            PriceFixing_2010_PSRate.Label = "#VAL{F}";

            PriceFixing_2010_PSRate.Color = Color.FromArgb(129, 101, 162);

            /***********************************************************************************************/

            //2010补充药品配送率序列
            Series ComplementarityCatalog_2010_PSRate = new Series("应急采购");

            //设置图表类型为柱状图
            ComplementarityCatalog_2010_PSRate.ChartType = SeriesChartType.Column;

            //设置图表边宽
            ComplementarityCatalog_2010_PSRate.BorderWidth = 1;

            //设置图表偏移量
            ComplementarityCatalog_2010_PSRate.ShadowOffset = 1;

            ComplementarityCatalog_2010_PSRate.IsValueShownAsLabel = true;

            ComplementarityCatalog_2010_PSRate.Label = "#VAL{F}";

            ComplementarityCatalog_2010_PSRate.Color = Color.FromArgb(192, 80, 78);


            #region 给序列集绑定数据


            HZ.Supervise.Web.Function.ChangeRate(NewDatatable, "DistributeRate", "addDistributeRate");

            HZ.Supervise.Web.Function.AddColumn(NewDatatable, "WareHouseRate", "SortSource");

            //如果数据源不为空同时又存在数据
            if (NewDatatable != null && NewDatatable.Rows.Count > 0)
            {
                for (int i = 0; i < NewDatatable.Rows.Count; i++)
                {
                    //如果为第一行，就初始化图表序列集合
                    if (i == 0)
                    {
                        //获取第一行中的医院名称
                        AreaName = NewDatatable.Rows[0]["AreaName"].ToString();

                        #region 初始化

                        //根据SortSource采购类型来绑定序列集合的数据
                        switch (NewDatatable.Rows[0]["SortSource"].ToString())
                        {

                            //日常采购
                            case "0":

                                //初始化采购类型为0的序列集
                                InitBindChart(NewDatatable.Rows[0],
                                              "0",
                                              BaseI,
                                              ComplementI,
                                              Base_2010I,
                                              PriceFixing_2010I,
                                              Complementarity_2010I,
                                    //BasicCatalog_Money,
                                    //ComplementarityCatalog_Money,
                                               BasicCatalog_2010_Money,
                                              PriceFixing_2010_Money,
                                              ComplementarityCatalog_2010_Money,
                                    //BasicCatalog_Count,
                                    ////ComplementarityCatalog_Count,
                                          BasicCatalog_2010_PSRate,
                                          PriceFixing_2010_PSRate,
                                          ComplementarityCatalog_2010_PSRate);
                                break;


                            //临时采购
                            case "1":

                                //初始化采购类型为1的序列集
                                InitBindChart(NewDatatable.Rows[0],
                                              "1",
                                              BaseI,
                                              ComplementI,
                                              Base_2010I,
                                              PriceFixing_2010I,
                                              Complementarity_2010I,
                                    //BasicCatalog_Money,
                                    //ComplementarityCatalog_Money,
                                              BasicCatalog_2010_Money,
                                              PriceFixing_2010_Money,
                                              ComplementarityCatalog_2010_Money,
                                    //BasicCatalog_Count,
                                    //ComplementarityCatalog_Count,
                                 BasicCatalog_2010_PSRate,
                                          PriceFixing_2010_PSRate,
                                          ComplementarityCatalog_2010_PSRate);
                                break;

                            //应急采购
                            case "2":

                                //初始化采购类型为2的序列集
                                InitBindChart(NewDatatable.Rows[0],
                                              "2",
                                              BaseI,
                                              ComplementI,
                                              Base_2010I,
                                              PriceFixing_2010I,
                                              Complementarity_2010I,
                                    //BasicCatalog_Money,
                                    //ComplementarityCatalog_Money,
                                              BasicCatalog_2010_Money,
                                              PriceFixing_2010_Money,
                                              ComplementarityCatalog_2010_Money,
                                    //BasicCatalog_Count,
                                    //ComplementarityCatalog_Count,
                                 BasicCatalog_2010_PSRate,
                                          PriceFixing_2010_PSRate,
                                          ComplementarityCatalog_2010_PSRate);
                                break;
                        }

                        #endregion

                        BaseI++;

                        ComplementI++;

                        Base_2010I++;

                        PriceFixing_2010I++;

                        Complementarity_2010I++;

                        //跳过下边的语句重新循环
                        continue;
                    }

                    //不为第一行数据
                    //如果当前行的医院名称与上一行中的名称相同
                    if (NewDatatable.Rows[i]["AreaName"].ToString().Equals(AreaName))
                    {
                        #region 绑定序列集合

                        switch (NewDatatable.Rows[i]["SortSource"].ToString())
                        {

                            //日常采购
                            case "0":

                                FinishBindChart(NewDatatable.Rows[i],
                                                "0",
                                                BaseI,
                                                ComplementI,
                                                Base_2010I,
                                                PriceFixing_2010I,
                                                Complementarity_2010I,
                                    //BasicCatalog_Money,
                                    //ComplementarityCatalog_Money,
                                                BasicCatalog_2010_Money,
                                                PriceFixing_2010_Money,
                                                ComplementarityCatalog_2010_Money,
                                    //BasicCatalog_Count,
                                    ////ComplementarityCatalog_Count,
                             BasicCatalog_2010_PSRate,
                                          PriceFixing_2010_PSRate,
                                          ComplementarityCatalog_2010_PSRate);
                                break;

                            //临时采购
                            case "1":

                                FinishBindChart(NewDatatable.Rows[i],
                                                "1",
                                                BaseI,
                                                ComplementI,
                                                Base_2010I,
                                                PriceFixing_2010I,
                                                Complementarity_2010I,
                                    //BasicCatalog_Money,
                                    //ComplementarityCatalog_Money,
                                                BasicCatalog_2010_Money,
                                                PriceFixing_2010_Money,
                                                ComplementarityCatalog_2010_Money,
                                    //BasicCatalog_Count,
                                    ////ComplementarityCatalog_Count,
                                 BasicCatalog_2010_PSRate,
                                          PriceFixing_2010_PSRate,
                                          ComplementarityCatalog_2010_PSRate);
                                break;

                            //应急采购
                            case "2":

                                FinishBindChart(NewDatatable.Rows[i],
                                                "2",
                                                BaseI,
                                                ComplementI,
                                                Base_2010I,
                                                PriceFixing_2010I,
                                                Complementarity_2010I,
                                    //BasicCatalog_Money,
                                    //ComplementarityCatalog_Money,
                                                BasicCatalog_2010_Money,
                                                PriceFixing_2010_Money,
                                                ComplementarityCatalog_2010_Money,
                                    //BasicCatalog_Count,
                                    ////ComplementarityCatalog_Count,
                                 BasicCatalog_2010_PSRate,
                                          PriceFixing_2010_PSRate,
                                          ComplementarityCatalog_2010_PSRate);
                                break;
                        }

                        #endregion

                        //把当前行的医院名称重新赋值给变量
                        AreaName = NewDatatable.Rows[i]["AreaName"].ToString();
                    }
                    else
                    {
                        #region 初始化

                        //根据SortSource采购类型来绑定序列集合的数据
                        switch (NewDatatable.Rows[i]["SortSource"].ToString())
                        {


                            //日常采购
                            case "0":

                                //初始化采购类型为0的序列集
                                InitBindChart(NewDatatable.Rows[i],
                                              "0",
                                              BaseI,
                                              ComplementI,
                                              Base_2010I,
                                              PriceFixing_2010I,
                                              Complementarity_2010I,
                                    //BasicCatalog_Money,
                                    //ComplementarityCatalog_Money,
                                              BasicCatalog_2010_Money,
                                              PriceFixing_2010_Money,
                                              ComplementarityCatalog_2010_Money,
                                    //BasicCatalog_Count,
                                    //ComplementarityCatalog_Count,
                             BasicCatalog_2010_PSRate,
                                          PriceFixing_2010_PSRate,
                                          ComplementarityCatalog_2010_PSRate);
                                break;

                            //临时采购
                            case "1":

                                //初始化采购类型为1的序列集
                                InitBindChart(NewDatatable.Rows[i],
                                              "1",
                                              BaseI,
                                              ComplementI,
                                              Base_2010I,
                                              PriceFixing_2010I,
                                              Complementarity_2010I,
                                    //BasicCatalog_Money,
                                    //ComplementarityCatalog_Money,
                                              BasicCatalog_2010_Money,
                                              PriceFixing_2010_Money,
                                              ComplementarityCatalog_2010_Money,
                                    //BasicCatalog_Count,
                                    //ComplementarityCatalog_Count,
                                 BasicCatalog_2010_PSRate,
                                          PriceFixing_2010_PSRate,
                                          ComplementarityCatalog_2010_PSRate);
                                break;

                            //应急采购
                            case "2":

                                //初始化采购类型为2的序列集
                                InitBindChart(NewDatatable.Rows[i],
                                              "2",
                                              BaseI,
                                              ComplementI,
                                              Base_2010I,
                                              PriceFixing_2010I,
                                              Complementarity_2010I,
                                    //BasicCatalog_Money,
                                    //ComplementarityCatalog_Money,
                                              BasicCatalog_2010_Money,
                                              PriceFixing_2010_Money,
                                              ComplementarityCatalog_2010_Money,
                                    //BasicCatalog_Count,
                                    ////ComplementarityCatalog_Count,
                                           BasicCatalog_2010_PSRate,
                                          PriceFixing_2010_PSRate,
                                          ComplementarityCatalog_2010_PSRate);
                                break;
                        }

                        #endregion

                        //把当前行的医院名称重新赋值给变量
                        AreaName = NewDatatable.Rows[i]["AreaName"].ToString();

                        BaseI++;

                        ComplementI++;

                        Base_2010I++;

                        PriceFixing_2010I++;

                        Complementarity_2010I++;
                    }
                }

                //提示按钮隐藏
                this.lblnull.Visible = false;

                #region 金额序列集合加入金额图表中


                //2010基本药物采购金额加入图表中
                BasicCatalog_2010_Money.IsValueShownAsLabel = true;
                ChartPurchasing.Series.Add(BasicCatalog_2010_Money);
                ChartPurchasing.Series["日常采购"].ChartArea = "ChartAreaPurchasing";

                //2010限价品种采购金额序列
                PriceFixing_2010_Money.IsValueShownAsLabel = true;
                ChartPurchasing.Series.Add(PriceFixing_2010_Money);
                ChartPurchasing.Series["临时采购"].ChartArea = "ChartAreaPurchasing";

                //2010补充药品采购金额序列
                PriceFixing_2010_Money.IsValueShownAsLabel = true;
                ChartPurchasing.Series.Add(ComplementarityCatalog_2010_Money);
                ChartPurchasing.Series["应急采购"].ChartArea = "ChartAreaPurchasing";

                #endregion

                #region 数量序列集合加入数量图表中

                this.ChartInStorage.Series.Add(BasicCatalog_2010_PSRate);

                this.ChartInStorage.Series.Add(PriceFixing_2010_PSRate);

                this.ChartInStorage.Series.Add(ComplementarityCatalog_2010_PSRate);

                this.ChartInStorage.Series["日常采购"].ChartArea = "ChartAreaStorage";

                this.ChartInStorage.Series["临时采购"].ChartArea = "ChartAreaStorage";

                this.ChartInStorage.Series["应急采购"].ChartArea = "ChartAreaStorage";



                ChartInStorage.ChartAreas["ChartAreaStorage"].AxisX.IsMarginVisible = true;
                ChartInStorage.ChartAreas["ChartAreaStorage"].AxisX.LabelStyle.Font = new Font("宋体", 8);
                ChartInStorage.ChartAreas["ChartAreaStorage"].Area3DStyle.Enable3D = false;

                ChartInStorage.Series["日常采购"]["PointWidth"] = "0.5";
                ChartInStorage.Series["临时采购"]["PointWidth"] = "0.5";
                ChartInStorage.Series["应急采购"]["PointWidth"] = "0.5";


                ChartInStorage.ChartAreas["ChartAreaStorage"].AxisX.MajorGrid.Interval = 1;
                ChartInStorage.ChartAreas["ChartAreaStorage"].AxisX.LineWidth = 1;
                ChartInStorage.ChartAreas["ChartAreaStorage"].AxisY.LineWidth = 1;


                ChartInStorage.ChartAreas["ChartAreaStorage"].AxisY.Title = "配送率";
                ChartInStorage.ChartAreas["ChartAreaStorage"].AxisX.Title = "地区";
                #endregion

                #region 图表属性设置

                ChartPurchasing.ChartAreas["ChartAreaPurchasing"].AxisX.IsMarginVisible = true;
                ChartPurchasing.ChartAreas["ChartAreaPurchasing"].AxisX.LabelStyle.Font = new Font("宋体", 8);
                ChartPurchasing.ChartAreas["ChartAreaPurchasing"].Area3DStyle.Enable3D = false;
                ChartPurchasing.Series["日常采购"]["PointWidth"] = "0.5";
                ChartPurchasing.Series["临时采购"]["PointWidth"] = "0.5";
                ChartPurchasing.Series["应急采购"]["PointWidth"] = "0.5";
                ChartPurchasing.ChartAreas["ChartAreaPurchasing"].AxisX.MajorGrid.Interval = 1;
                ChartPurchasing.ChartAreas["ChartAreaPurchasing"].AxisX.LineWidth = 1;
                ChartPurchasing.ChartAreas["ChartAreaPurchasing"].AxisY.LineWidth = 1;

                ChartPurchasing.ChartAreas["ChartAreaPurchasing"].AxisY.Title = "金额（万元）";
                ChartPurchasing.ChartAreas["ChartAreaPurchasing"].AxisX.Title = "地区";

                #endregion
            }
            else
            {
                //隐藏金额图表
                this.ChartPurchasing.Visible = false;

                this.divTable.Visible = false;

                this.btnExcel.Visible = false;

                //提示按钮显示出来
                lblnull.Visible = true;
            }

            #endregion
        }

        /// <summary>
        /// 第一次绑定序列集合
        /// 董辉
        /// 2011-4-9 17:11
        /// </summary>
        /// <param name="row">当前行数据</param>
        /// <param name="ParameType">采购类型</param>
        /// <param name="BaseI">基本药品目录循环因子</param>
        /// <param name="ComplementI">补充目录循环因子</param>
        /// <param name="Base_2010I">2010基本药物循环因子</param>
        /// <param name="PriceFixing_2010I">2010限价品种循环因子</param>
        /// <param name="Complementarity_2010I">2010补充药品循环因子</param>
        /// <param name="BasicCatalog_Money">基本药物目录采购金额序列</param>
        /// <param name="ComplementarityCatalog_Money">补充目录采购金额序列</param>
        /// <param name="BasicCatalog_2010_Money">2010基本药物采购金额序列</param>
        /// <param name="PriceFixing_2010_Money">2010限价品种采购金额序列</param>
        /// <param name="ComplementarityCatalog_2010_Money">2010补充药品采购金额序列</param>
        /// <param name="BasicCatalog_Count">基本药物目录配送率序列</param>
        /// <param name="ComplementarityCatalog_Count">补充目录配送率序列</param>
        /// <param name="BasicCatalog_2010_Count">2010基本药物配送率序列</param>
        /// <param name="PriceFixing_2010_Count">2010限价品种配送率序列</param>
        /// <param name="ComplementarityCatalog_2010_Count">2010补充药品配送率序列</param>
        private void InitBindChart(DataRow row,
                                   string ParameType,
                                   int BaseI,
                                   int ComplementI,
                                   int Base_2010I,
                                   int PriceFixing_2010I,
                                   int Complementarity_2010I,
                                   Series BasicCatalog_2010_Money,
                                   Series PriceFixing_2010_Money,
                                   Series ComplementarityCatalog_2010_Money,
        Series BasicCatalog_2010_Count,
        Series PriceFixing_2010_Count,
        Series ComplementarityCatalog_2010_Count)
        {
            if (row != null)
            {
                switch (ParameType)
                {

                    //第一批基本药物
                    case "0":


                        //第一批基本药物采购金额序列
                        BasicCatalog_2010_Money.Points.AddXY(row["AreaName"].ToString(), Convert.ToDecimal(row["PurchaseAmountTotal"].ToString()) / 10000);
                        BasicCatalog_2010_Money.Points[Base_2010I].ToolTip = string.Format("{0}\n日常采购采购金额：{1}", row["AreaName"].ToString(), (Convert.ToDecimal(row["PurchaseAmountTotal"].ToString()) / 10000).ToString() + " 万元");


                        //第一批基本药物配送率序列
                        BasicCatalog_2010_Count.Points.AddXY(row["AreaName"].ToString(), row["DistributeRate"].ToString());
                        BasicCatalog_2010_Count.Points[Base_2010I].ToolTip = string.Format("{0}\n日常采购配送率：{1}", row["AreaName"].ToString(), row["addDistributeRate"].ToString());

                        //2010限价品种采购金额序列
                        PriceFixing_2010_Money.Points.AddXY(row["AreaName"].ToString(), 0);
                        PriceFixing_2010_Money.Points[PriceFixing_2010I].ToolTip = string.Format("{0}\n临时采购采购金额：{1}", row["AreaName"].ToString(), "0 万元");

                        //2010限价品种配送率序列
                        PriceFixing_2010_Count.Points.AddXY(row["AreaName"].ToString(), 0);
                        PriceFixing_2010_Count.Points[PriceFixing_2010I].ToolTip = string.Format("{0}\n临时采购配送率：{1}", row["AreaName"].ToString(), "0%");

                        //2010补充目录采购金额序列
                        ComplementarityCatalog_2010_Money.Points.AddXY(row["AreaName"].ToString(), 0);
                        ComplementarityCatalog_2010_Money.Points[Complementarity_2010I].ToolTip = string.Format("{0}\n应急采购采购金额：{1}", row["AreaName"].ToString(), "0 万元");

                        //2010补充目录配送率序列
                        ComplementarityCatalog_2010_Count.Points.AddXY(row["AreaName"].ToString(), 0);
                        ComplementarityCatalog_2010_Count.Points[Complementarity_2010I].ToolTip = string.Format("{0}\n应急采购配送率：{1}", row["AreaName"].ToString(), "0%");

                        break;

                    //2010限价品种
                    case "1":

                        //2010基本药物采购金额序列
                        BasicCatalog_2010_Money.Points.AddXY(row["AreaName"].ToString(), 0);
                        BasicCatalog_2010_Money.Points[Base_2010I].ToolTip = string.Format("{0}\n日常采购采购金额：{1}", row["AreaName"].ToString(), "0 万元");

                        ////2010基本药物配送率序列
                        BasicCatalog_2010_Count.Points.AddXY(row["AreaName"].ToString(), 0);
                        BasicCatalog_2010_Count.Points[Base_2010I].ToolTip = string.Format("{0}\n日常采购配送率：{1}", row["AreaName"].ToString(), "0%");

                        //2010限价品种采购金额序列
                        PriceFixing_2010_Money.Points.AddXY(row["AreaName"].ToString(), Convert.ToDecimal(row["PurchaseAmountTotal"].ToString()) / 10000);
                        PriceFixing_2010_Money.Points[PriceFixing_2010I].ToolTip = string.Format("{0}\n临时采购采购金额：{1}", row["AreaName"].ToString(), (Convert.ToDecimal(row["PurchaseAmountTotal"].ToString()) / 10000).ToString() + " 万元");


                        //2010限价品种配送率序列
                        PriceFixing_2010_Count.Points.AddXY(row["AreaName"].ToString(), row["DistributeRate"].ToString());
                        PriceFixing_2010_Count.Points[PriceFixing_2010I].ToolTip = string.Format("{0}\n临时采购配送率：{1}", row["AreaName"].ToString(), row["addDistributeRate"].ToString());

                        //2010补充药品采购金额序列
                        ComplementarityCatalog_2010_Money.Points.AddXY(row["AreaName"].ToString(), 0);
                        ComplementarityCatalog_2010_Money.Points[Complementarity_2010I].ToolTip = string.Format("{0}\n应急采购采购金额：{1}", row["AreaName"].ToString(), "0 万元");

                        //2010补充药品配送率序列
                        ComplementarityCatalog_2010_Count.Points.AddXY(row["AreaName"].ToString(), 0);
                        ComplementarityCatalog_2010_Count.Points[Complementarity_2010I].ToolTip = string.Format("{0}\n应急采购配送率：{1}", row["AreaName"].ToString(), "0%");

                        break;

                    //2010补充药品
                    case "2":

                        //2010基本药物采购金额序列
                        BasicCatalog_2010_Money.Points.AddXY(row["AreaName"].ToString(), 0);
                        BasicCatalog_2010_Money.Points[Base_2010I].ToolTip = string.Format("{0}\n日常采购采购金额：{1}", row["AreaName"].ToString(), "0 万元");

                        //2010基本药物配送率序列
                        BasicCatalog_2010_Count.Points.AddXY(row["AreaName"].ToString(), 0);
                        BasicCatalog_2010_Count.Points[Base_2010I].ToolTip = string.Format("{0}\n日常采购配送率：{1}", row["AreaName"].ToString(), "0%");

                        //2010限价品种采购金额序列
                        PriceFixing_2010_Money.Points.AddXY(row["AreaName"].ToString(), 0);
                        PriceFixing_2010_Money.Points[PriceFixing_2010I].ToolTip = string.Format("{0}\n临时采购采购金额：{1}", row["AreaName"].ToString(), "0 万元");

                        //2010限价品种配送率序列
                        PriceFixing_2010_Count.Points.AddXY(row["areaname"].ToString(), 0);
                        PriceFixing_2010_Count.Points[PriceFixing_2010I].ToolTip = string.Format("{0}\n临时采购配送率：{1}", row["areaname"].ToString(), "0%");

                        //2010补充药品采购金额序列
                        ComplementarityCatalog_2010_Money.Points.AddXY(row["AreaName"].ToString(), Convert.ToDecimal(row["PurchaseAmountTotal"].ToString()) / 10000);
                        ComplementarityCatalog_2010_Money.Points[Complementarity_2010I].ToolTip = string.Format("{0}\n应急采购采购金额：{1}", row["AreaName"].ToString(), (Convert.ToDecimal(row["PurchaseAmountTotal"].ToString()) / 10000).ToString() + " 万元");


                        ////2010补充药品配送率序列
                        ComplementarityCatalog_2010_Count.Points.AddXY(row["AreaName"].ToString(), row["DistributeRate"].ToString());
                        ComplementarityCatalog_2010_Count.Points[Complementarity_2010I].ToolTip = string.Format("{0}\n应急采购配送率：{1}", row["AreaName"].ToString(), row["addDistributeRate"].ToString());

                        break;

                }
            }
        }


        /// <summary>
        /// 最终绑定序列集合
        /// 董辉
        /// 2011-4-9 17:21
        /// </summary>
        /// <param name="row">当前行数据</param>
        /// <param name="ParameType">采购类型</param>
        /// <param name="BaseI">基本药品目录循环因子</param>
        /// <param name="ComplementI">补充目录循环因子</param>
        /// <param name="Base_2010I">2010基本药物循环因子</param>
        /// <param name="PriceFixing_2010I">2010限价品种循环因子</param>
        /// <param name="Complementarity_2010I">2010补充目录循环因子</param>
        /// <param name="BasicCatalog_Money">基本药物目录采购金额序列</param>
        /// <param name="ComplementarityCatalog_Money">补充目录采购金额序列</param>
        /// <param name="BasicCatalog_2010_Money">2010基本药物采购金额序列</param>
        /// <param name="PriceFixing_2010_Money">2010限价品种采购金额序列</param>
        /// <param name="ComplementarityCatalog_2010_Money">2010补充目录采购金额序列</param>
        /// <param name="BasicCatalog_Count">基本药物目录配送率序列</param>
        /// <param name="ComplementarityCatalog_Count">补充目录配送率序列</param>
        /// <param name="BasicCatalog_2010_Count">2010基本药物配送率序列</param>
        /// <param name="PriceFixing_2010_Count">//2010限价品种配送率序列</param>
        /// <param name="ComplementarityCatalog_2010_Count">2010补充目录配送率序列</param>
        private void FinishBindChart(DataRow row,
                                     string ParameType,
                                     int BaseI,
                                     int ComplementI,
                                     int Base_2010I,
                                     int PriceFixing_2010I,
                                     int Complementarity_2010I,

                                     Series BasicCatalog_2010_Money,
                                     Series PriceFixing_2010_Money,
                                     Series ComplementarityCatalog_2010_Money,

        Series BasicCatalog_2010_Count,
        Series PriceFixing_2010_Count,
        Series ComplementarityCatalog_2010_Count)
        {
            if (row != null)
            {
                switch (ParameType)
                {

                    //第一批基本药物
                    case "0":

                        //上次绑定的第一批基本药物采购金额数据移除，重新绑定新的数据
                        BasicCatalog_2010_Money.Points.RemoveAt(Base_2010I - 1);
                        //第一批基本药物采购金额序列
                        BasicCatalog_2010_Money.Points.AddXY(row["AreaName"].ToString(), Convert.ToDecimal(row["PurchaseAmountTotal"].ToString()) / 10000);
                        BasicCatalog_2010_Money.Points[Base_2010I - 1].ToolTip = string.Format("{0}\n日常采购采购金额：{1}", row["AreaName"].ToString(), (Convert.ToDecimal(row["PurchaseAmountTotal"].ToString()) / 10000).ToString() + " 万元");


                        //上次绑定的第一批基本药物配送率数据移除，重新绑定新的数据
                        BasicCatalog_2010_Count.Points.RemoveAt(Base_2010I - 1);
                        //第一批基本药物配送率序列
                        BasicCatalog_2010_Count.Points.AddXY(row["AreaName"].ToString(), row["DistributeRate"].ToString());
                        BasicCatalog_2010_Count.Points[Base_2010I - 1].ToolTip = string.Format("{0}\n日常采购配送率：{1}", row["AreaName"].ToString(), row["addDistributeRate"].ToString());

                        break;

                    //2010限价品种
                    case "1":

                        //上次绑定的2010限价品种采购金额数据移除，重新绑定新的数据
                        PriceFixing_2010_Money.Points.RemoveAt(PriceFixing_2010I - 1);
                        //2010限价品种采购金额序列
                        PriceFixing_2010_Money.Points.AddXY(row["AreaName"].ToString(), Convert.ToDecimal(row["PurchaseAmountTotal"].ToString()) / 10000);
                        PriceFixing_2010_Money.Points[PriceFixing_2010I - 1].ToolTip = string.Format("{0}\n临时采购采购金额：{1}", row["AreaName"].ToString(), (Convert.ToDecimal(row["PurchaseAmountTotal"].ToString()) / 10000).ToString() + " 万元");


                        ////上次绑定的2010限价品种配送率数据移除，重新绑定新的数据
                        PriceFixing_2010_Count.Points.RemoveAt(PriceFixing_2010I - 1);
                        //2010限价品种配送率序列
                        PriceFixing_2010_Count.Points.AddXY(row["AreaName"].ToString(), row["DistributeRate"].ToString());
                        PriceFixing_2010_Count.Points[PriceFixing_2010I - 1].ToolTip = string.Format("{0}\n临时采购配送率：{1}", row["AreaName"].ToString(), row["addDistributeRate"].ToString());

                        break;

                    //2010补充目录
                    case "2":

                        //上次绑定的2010补充目录采购金额数据移除，重新绑定新的数据
                        ComplementarityCatalog_2010_Money.Points.RemoveAt(Complementarity_2010I - 1);
                        //2010补充目录采购金额序列
                        ComplementarityCatalog_2010_Money.Points.AddXY(row["AreaName"].ToString(), Convert.ToDecimal(row["PurchaseAmountTotal"].ToString()) / 10000);
                        ComplementarityCatalog_2010_Money.Points[Complementarity_2010I - 1].ToolTip = string.Format("{0}\n应急采购采购金额：{1}", row["AreaName"].ToString(), (Convert.ToDecimal(row["PurchaseAmountTotal"].ToString()) / 10000).ToString() + " 万元");


                        ////上次绑定的2010补充目录配送率数据移除，重新绑定新的数据
                        ComplementarityCatalog_2010_Count.Points.RemoveAt(Complementarity_2010I - 1);
                        //2010补充目录配送率序列
                        ComplementarityCatalog_2010_Count.Points.AddXY(row["AreaName"].ToString(), row["DistributeRate"].ToString());
                        ComplementarityCatalog_2010_Count.Points[Complementarity_2010I - 1].ToolTip = string.Format("{0}\n应急采购配送率：{1}", row["AreaName"].ToString(), row["addDistributeRate"].ToString());

                        break;
                }
            }
        }

            #endregion
        #endregion
    }
}
